﻿@model Consumer.Models.CourseGradebookModel

@if (Model.EnrolledUsers.Count == 0)
{
    <p>
        No one is currently enrolled in this course.
    </p>
}
else
{
    if (Model.Assignments.Count == 0)
    {
        <p>
            This course does not have any assignments.
        </p>
    }
    else
    {
        <p>
            Here are the scores for all the people currently enrolled in this course.
        </p>

        <table class="table">
            <tr>
                <th></th>
                @foreach (var assignment in Model.Assignments.OrderBy(a => a.Name))
                {
                    <th>@assignment.Name</th>
                }
            </tr>
            @foreach (var user in Model.EnrolledUsers.OrderBy(u => u.FullName))
            {
                <tr>
                    <td>
                        <span title="Username: @user.UserName">
                            @user.FullName
                        </span>
                    </td>
                    @foreach (var assignment in Model.Assignments.OrderBy(a => a.Name))
                    {
                        <td>
                            @Model.Scores[new Tuple<string, int>(@user.Id, @assignment.AssignmentId)]
                        </td>
                    }
                </tr>
            }
        </table>
    }
}